#include "dominion.h"
#include "dominion_helpers.h"
#include "testCards.h"
#include "rngs.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <math.h>
void getRandKingdomCards(int *kingdomCards);

int testSteward(struct gameState *state,int choice1,int choice2,int choice3)
{
    struct gameState *oldState = newGame();
    *oldState = *state;
    int i,handPos=-1;
    for(i=0;i<state->handCount[state->whoseTurn];i++)
    {
        if(state->hand[state->whoseTurn][i] == steward)
        {
            handPos = i;
            break;
        }
    }
    if(handPos<0)
    {
        printf("steward not in hand of current player\n");
        free(oldState);
        return -1;
    }
    if(cardEffect(steward,choice1,choice2,choice2,state,handPos,0) == -1)
    {
        printf("cardEffect returned -1\n");
        free(oldState);
        return -1;
    }
    if(choice1 == 1)
    {
        if(state->handCount[state->whoseTurn] ==
           oldState->handCount[state->whoseTurn]+1
          )
        {
            printf("steward worked correctly\n");
            free(oldState);
            return 0;
        }
        printf("steward failed\n");
        free(oldState);
        return -1;
    }
    if(choice1 == 2)
    {
        if(state->coins == oldState->coins+2)
        {
            printf("steward worked correctly on choice1=2\n");
            free(oldState);
            return 0;
        }
        printf("steward failed\n");
        free(oldState);
        return -1;
    }
    if(choice1 == 3)
    {
        if(state->handCount[state->whoseTurn]==
           oldState->handCount[state->whoseTurn]-3&&
           state->discardCount[state->whoseTurn] ==
           oldState->discardCount[state->whoseTurn])
        {
            printf("steward worked correctly on choice1=3i\n");
            free(oldState);
            return 0;
        }
        printf("steward failed\n");
        free(oldState);
        return -1;
    }
    printf("steward failed\n");
    free(oldState);
    return -1;
}

int testSmithy(struct gameState *state)
{
    struct gameState *oldState = newGame();
    *oldState = *state;
    int i,handPos=-1;
    for(i=0;i<state->handCount[state->whoseTurn];i++)
    {
        if(state->hand[state->whoseTurn][i] == smithy)
        {
            handPos = i;
            break;
        }
    }
    if(handPos<0)
    {
        printf("smithy not in hand of current player\n");
        free(oldState);
        return -1;
    }

    if(cardEffect(smithy,0,0,0,state,handPos,0) == -1)
    {
        printf("cardEffect returned -1\n");
        free(oldState);
        return -1;
    }
    if(state->handCount[state->whoseTurn] ==
       oldState->handCount[state->whoseTurn]+3)
    {
        printf("smithy worked correctly\n");
        free(oldState);
        return 0;
    }
    else
    {
        printf("Smithy failed\n");
        free(oldState);
        return -1;
    }
}


int testMinion(struct gameState *state, int supplyChoice, int supplyChoice2){

	struct gameState *oldState = newGame();
	*oldState = *state;
	int numActions = state->numActions;
	int numCoins = state->coins;
	int discardPile = state->discardCount[0];
	int numCards = state->handCount[1];
	int i, handPos=-1;
	for(i=0; i<state->handCount[state->whoseTurn];i++)
	{
		if(state->hand[state->whoseTurn][i] == minion){
		handPos = i;
		break;
		}
	}
	
	    if(handPos<0)
    {
        printf("minion not in hand of current player\n");
        free(oldState);
        return -1;
    }
    if(state->supplyCount[supplyChoice] == -1)
    {
        printf("supply choice not in game\n");
    }
	
	if(cardEffect(remodel,supplyChoice,supplyChoice2,0,state,handPos,0) == -1)
    {
        printf("cardEffect returned -1\n");
        free(oldState);
        return -1;
    }
	
	//check actions
	if(state->numActions == numActions)
		printf("Minion Actions Test Passed.\n");
	else{
		printf("Minion Actions Test Failed.\n");
		return -1;
		}
		
	//test player choice
	if((state->coins + 2 == numCoins) || state->discardCount[0] + 4 == discardPile)
		printf("Minion Test2 Passed.\n");
	else{
		printf("Minion Test2 Failed.\n");
		return -1;
		}
	
	//test other player's hand
	if(numCards <= 4) {
		if(state->handCount[1] == numCards){
			printf("Other player's handCount is Correct.\n");
			}
		else{
			printf("Other player's handCount is  Not Correct.\n");
			return -1;
		}
		}
	else
		if(state->handCount[1] == 4){
			printf("Other player's handCount is Correct.\n");
			}
		else{
			printf("Other player's handCount is  Not Correct.\n");
			return -1;
			}
		
	return 0;

}

int testRemodel(struct gameState *state, int supplyChoice, int supplyChoice2){

	struct gameState *oldState = newGame();
	*oldState = *state;
	int discardPile = oldState->discardCount[oldState->whoseTurn];
	int i, handPos=-1;
	for(i=0; i<state->handCount[state->whoseTurn];i++)
	{
		if(state->hand[state->whoseTurn][i] == remodel){
		handPos = i;
		break;
		}
	}
	
	    if(handPos<0)
    {
        printf("remodel not in hand of current player\n");
        free(oldState);
        return -1;
    }
    if(state->supplyCount[supplyChoice] == -1)
    {
        printf("supply choice not in game\n");
    }
	
	if(cardEffect(remodel,supplyChoice,supplyChoice2,0,state,handPos,0) == -1)
    {
        printf("cardEffect returned -1\n");
        free(oldState);
        return -1;
    }
	
	//check discard pile
	if(discardPile + 1 == state->discardCount[state->whoseTurn])
		printf("Discard Count Test Passed.\n");
	else{
		printf("Discard Count Test Failed.\n");
		return -1;
		}
		
	
	return 0;
	

}

int testFeast(struct gameState *state, int supplyChoice)
{
	struct gameState *oldState = newGame();
	*oldState = *state;
	int i, handPos=-1;
	for(i=0; i<state->handCount[state->whoseTurn];i++)
	{
		if(state->hand[state->whoseTurn][i] == feast){
		handPos = i;
		break;
		}
	}
	
	    if(handPos<0)
    {
        printf("feast not in hand of current player\n");
        free(oldState);
        return -1;
    }
    if(state->supplyCount[supplyChoice] == -1)
    {
        printf("supply choice not in game\n");
    }
	printf("4\n");
	if(cardEffect(feast,supplyChoice,0,0,state,handPos,0) == -1)
    {
		printf("cardEffect returned -1\n");
        free(oldState);
        return -1;
    }
	printf("5\n");
	return 0;
	
}

int testEmbargo(struct gameState *state,int supplyChoice)
{
    struct gameState *oldState = newGame();
    *oldState = *state;
    int i,handPos=-1;
    for(i=0;i<state->handCount[state->whoseTurn];i++)
    {
        if(state->hand[state->whoseTurn][i] == embargo)
        {
            handPos = i;
            break;
        }
    }
    if(handPos<0)
    {
        printf("embargo not in hand of current player\n");
        free(oldState);
        return -1;
    }
    if(state->supplyCount[supplyChoice] == -1)
    {
        printf("supply choice not in game\n");
    }
    if(cardEffect(embargo,supplyChoice,0,0,state,handPos,0) == -1)
    {
        printf("cardEffect returned -1\n");
        free(oldState);
        return -1;
    }
/*    printf("Coins: %d\t%d\n", state->coins, oldState->coins);
    printf("handCount: %d\t%d\n",
           state->handCount[state->whoseTurn],
           oldState->handCount[state->whoseTurn]);
    printf("discardCount %d\t%d\n",
           state->discardCount[state->whoseTurn],
           oldState->discardCount[state->whoseTurn]);
    printf("embargoTokens: %d\t%d\n",
            state->embargoTokens[supplyChoice],
            oldState->embargoTokens[supplyChoice]);

*/
    if(state->coins == oldState->coins+2 &&
       state->handCount[state->whoseTurn] ==
       oldState->handCount[state->whoseTurn]-1 &&
       state->discardCount[state->whoseTurn] ==
       oldState->discardCount[state->whoseTurn] &&
       state->embargoTokens[supplyChoice] ==
       oldState->embargoTokens[supplyChoice]+1)
    {
        printf("embargo worked correctly\n");
        free(oldState);
        return 0;
    }
    free(oldState);
    return -1;


}

int testTreasure_Map(struct gameState *state)
{
    struct gameState *oldState = newGame();
    *oldState = *state;
    int i,secondTreasure=-1,handPos=-1;
    for(i=0;i<state->handCount[state->whoseTurn];i++)
    {
        if(state->hand[state->whoseTurn][i] == treasure_map)
        {
            handPos = i;
            break;
        }
    }
    if(handPos<0)
    {
        printf("treasure_map not in hand of current player\n");
        free(oldState);
        return -1;
    }
    for(i=0;i<state->handCount[state->whoseTurn];i++)
    {
        if(i==handPos){continue;}
        if(state->hand[state->whoseTurn][i] == treasure_map)
        {
            secondTreasure = 1;
            break;
        }
    }
    if(secondTreasure == -1){
        printf("Only one treasure card in hand\n");
        //free(oldState);
        //return -1;
    }
    if(cardEffect(treasure_map,0,0,0,state,handPos,0) == -1)
    {
        printf("cardEffect returned -1\n");
        free(oldState);
        return -1;
    }

    if(state->deckCount[state->whoseTurn] ==
       oldState->deckCount[state->whoseTurn]+4 &&
       state->handCount[state->whoseTurn] ==
       oldState->handCount[state->whoseTurn]-2
       )
    {
       for(i=oldState->deckCount[state->whoseTurn];
           i<state->deckCount[state->whoseTurn];i++)
       {
           printf("%d\n",state->deck[state->whoseTurn][i]);
            if(state->deck[state->whoseTurn][i] != gold)
            {
                printf("Didn't put 4 gold cards on top of deck\n");
                free(oldState);
                return -1;
            }
       }
       printf("treasure_map worked correctly\n");
       free(oldState);
       return 0;
    }
    printf("treasure_map failed on deckcount or handcount check\n");
    free(oldState);
    return -1;

}
int testSea_Hag(struct gameState *state)
{
    struct gameState *oldState = newGame();
    *oldState = *state;
    int i,handPos=-1;
    for(i=0;i<state->handCount[state->whoseTurn];i++)
    {
        if(state->hand[state->whoseTurn][i] == sea_hag)
        {
            handPos = i;
            break;
        }
    }
    if(handPos<0)
    {
        printf("Sea_Hag not in hand of current player\n");
        free(oldState);
        return -1;
    }
    if(cardEffect(sea_hag,0,0,0,state,handPos,0) == -1)
    {
        printf("cardEffect returned -1\n");
        free(oldState);
        return -1;
    }
    for(i=0;i<state->numPlayers;i++)
    {
        if(i == state->whoseTurn){continue;}
        printf("%d\t%d\n%d\t%d\n%d\n", state->discardCount[i],oldState->discardCount[i],state->deckCount[i],oldState->deckCount[i],state->deck[i][state->deckCount[i]-1]);
        if(!(state->discardCount[i] == oldState->discardCount[i]+1 &&
           state->deckCount[i] == oldState->deckCount[i] &&
           state->deck[i][state->deckCount[i]-1] == curse))
        {
            printf("sea_hag failed\n");
            free(oldState);
            return -1;
        }
    }
    printf("sea_hag worked correctly\n");
    free(oldState);
    return 0;
}
int testSalvager(struct gameState *state)
{
    struct gameState *oldState = newGame();
    *oldState = *state;
    int i,salvagedCard,salvagedCardPos, handPos=-1;
    for(i=0;i<state->handCount[state->whoseTurn];i++)
    {
        if(state->hand[state->whoseTurn][i] == salvager)
        {
            handPos = i;
            break;
        }
    }
    if(handPos<0)
    {
        printf("Salvager not in hand of current player\n");
        free(oldState);
        return -1;
    }
    if(state->handCount[state->whoseTurn] > 1)
    {
 //       printf("TESTING1");
        salvagedCardPos = (rand() % state->handCount[state->whoseTurn]);
        while(salvagedCardPos == handPos)
        {
         salvagedCardPos = (rand() % state->handCount[state->whoseTurn]);
        }
        salvagedCard = state->hand[state->whoseTurn][salvagedCardPos];
    }

    printf("%d\t%d\n",salvagedCard,salvagedCardPos);
    if(cardEffect(salvager,1,0,0,state,handPos,0) == -1)
    {
        printf("cardEffect returned -1\n");
        free(oldState);
        return -1;
    }
    printf("%d\t%d\n%d\t%d\n%d\t%d\n",state->numBuys,oldState->numBuys,state->discardCount[state->whoseTurn],oldState->discardCount[state->whoseTurn],state->handCount[state->whoseTurn],oldState->handCount[state->whoseTurn]);
    if(state->numBuys == oldState->numBuys+1 &&
       state->discardCount[state->whoseTurn] ==
       oldState->discardCount[state->whoseTurn]+1 &&
      (state->handCount[state->whoseTurn] ==
       oldState->handCount[state->whoseTurn]-2 ||
       state->handCount[state->whoseTurn] == 0)
      )
    {
//        printf("TESTING2");
        if(1)
        {
            if(state->coins == (oldState->coins
               + getCost(salvagedCard)))
            {
                printf("Salvager worked correctly");
                free(oldState);
                return 0;
            }
            free(oldState);
            return -1;
        }
        printf("Salvager worked correctly");
        free(oldState);
        return 0;
    }
//    printf("TEST3");
    free(oldState);
    return -1;
}

int testOutpost(struct gameState *state)
{
    struct gameState *oldState = newGame();
    *oldState = *state;
    int i,handPos=-1;
    for(i=0;i<state->handCount[state->whoseTurn];i++)
    {
        if(state->hand[state->whoseTurn][i] == outpost)
        {
            handPos = i;
            break;
        }
    }
    if(handPos<0)
    free(oldState);
    return -1;
}
int testCutpurse(struct gameState *state)
{
    struct gameState *oldState = newGame();
    *oldState = *state;
    int i,j, handPos=-1;
    for(i=0;i<state->handCount[state->whoseTurn];i++)
    {
        if(state->hand[state->whoseTurn][i] == cutpurse)
        {
            handPos = i;
            break;
        }
    }
    if(handPos<0)
    {
        printf("cutpurse not in hand of current player\n");
        free(oldState);
        return -1;
    }
//    printf("%d %d\n",state->coins,oldState->coins);
    if(cardEffect(cutpurse,0,0,0,state,handPos,0)== -1)
    {
        printf("cardEffect returned -1\n");
        free(oldState);
        return -1;
    }
//    printf("Coins: %d\tOld: %d\n",state->coins,oldState->coins);
    if(state->handCount[state->whoseTurn] ==
       oldState->handCount[state->whoseTurn]-1 &&
       state->coins == oldState->coins+2)
    {
        for(i=0;i<state->numPlayers;i++)
        {
            if(i==state->whoseTurn){continue;}
            for(j=0;j<oldState->handCount[i];j++)
            {
                if(oldState->hand[i][j] == copper)
                {
                    if(!(state->handCount[i] ==
                        oldState->handCount[i]-1 ||
                        state->handCount[i] == 0))
                    {
                        printf("cutpurse failed to remove cards from                                  other players hands\n");
                        free(oldState);
                        return -1;
                    }
                    break;
                }
            }

        }
        printf("cutpurse worked correctly\n");
        free(oldState);
        return 0;
    }
    else
    {
        printf("cutpurse failed to either give coins to the player or remove the card from hand\n");
        free(oldState);
        return -1;
    }



}
void getRandKingdomCards(int *kingdomCards)
{
    int i,j, temp;
    for (i=0;i<10;i++)
    {
        temp = (rand() % 20 + 7);
        for (j=0;j<=i;j++)
        {
            if (temp == kingdomCards[j])
            {
                i--;
                break;
            } else if (j==i){kingdomCards[i] = temp;}
        }
    }
}

int main(int argc, char *argv[])
{
    struct gameState *state = newGame();
    struct gameState *startingState = newGame();
    int i,kingdomCards[10],supplyChoice, supplyChoice2;
    //int buyableCards[13];
    getRandKingdomCards(kingdomCards);
    state->supplyCount[copper] = 60;
    state->supplyCount[silver] = 40;
    state->supplyCount[gold] = 30;
    state->supplyCount[estate] = 12;
    state->supplyCount[duchy] = 12;
    state->supplyCount[province] = 12;
    for(i=0;i<10;i++)
    {
        state->supplyCount[kingdomCards[i]] = 10;
    }

    state->whoseTurn = 0;
    state->numPlayers = 2;
    state->numActions = 1;
    state->numBuys = 1;
    for(i=0;i<6;i++)
    {
        state->hand[0][i] = silver;
        state->hand[1][i] = copper;
        state->discard[0][i] = duchy;
        state->discard[1][i] = estate;
        state->deck[0][i] = i+5;
        state->deck[1][i] = i+15;
    }
    state->handCount[0] = 5;
    state->handCount[1] = 5;
    state->discardCount[0] = 5;
    state->discardCount[1] = 5;
    state->deckCount[0] = 5;
    state->deckCount[1] = 5;
    *startingState = *state;
    state->hand[0][4] = cutpurse;
    updateCoins(0,state,0);
//Cutpurse Case 1: cutpurse and other player has copper
    if(testCutpurse(state) == 0)
    {
        printf("cutPurse passed the first test\n");
    }
    else{
        printf("cutpurse Failed by returning -1 on a good state)\n");
    }
    *state = *startingState;
//Cutpurse Case 2: No cutpurse
    if(testCutpurse(state) == -1)
    {
        printf("cupurse passed the second test\n");
    }
    else{
        printf("cutpurse Failed by returning 0 on a bad state\n");
    }
    *state = *startingState;
    for(i=0;i<6;i++)
    {
        state->hand[1][i] = duchy;
    }
    state->hand[0][4] = cutpurse;
    updateCoins(0,state,0);
//Cutpurse Case 3: No copper
    if(testCutpurse(state) == 0)
    {
        printf("cutPurse passed the third test\n");
    }
    else{
        printf("cutpurse Failed by returning -1 on a good state\n");
    }
    *state = *startingState;
    state->hand[0][4] = outpost;
//Outpost Case 1; Outpost played
    if(testOutpost(state) == 0)
    {
        printf("Outpost passed the first test case\n");
    }
    else
    {
        printf("Outpost failed the first test case\n");
    }

    *state = *startingState;
    state->hand[0][4] = salvager;
    updateCoins(0,state,0);
//Salvager Case 1: Salvager in hand
    if(testSalvager(state) == 0)
    {
        printf("Salvager passed the first test case\n");
    }
    else
    {
        printf("Salvager failed the first test case\n");
    }
    *state = *startingState;
    state->hand[0][4] = sea_hag;
    updateCoins(0,state,0);
//Sea_hag Case 1: sea_hag in hand
    if(testSea_Hag(state) == 0)
    {
        printf("sea_hag passed the first test case\n");
    }
    else
    {
        printf("sea_hag failed the first test case\n");
    }
    *state = *startingState;
    state->hand[0][3] = treasure_map;
    state->hand[0][4] = treasure_map;
    updateCoins(0,state,0);
//treasure_map Case 1: two treasure maps in hand
    if(testTreasure_Map(state) == 0)
    {
        printf("treasure_map passed the first test case\n");
    }
    else
    {
        printf("treasure_map failaed the first test case\n");
    }
    *state = *startingState;
    state->hand[0][4] = treasure_map;
    updateCoins(0,state,0);
//treasure_map Case 1: one treasure maps in hand
    if(testTreasure_Map(state) == 0)
    {
        printf("treasure_map passed the second test case\n");
    }
    else
    {
        printf("treasure_map failed the second test case\n");
    }
    *state = *startingState;
    state->hand[0][4] = embargo;
    updateCoins(0,state,0);
////Embargo Case 1: embargo a valid kingdom card
    supplyChoice= rand()%10;
    if(testEmbargo(state,kingdomCards[supplyChoice]) == 0)
    {
        printf("embargo passed the first test case\n");
    }
    else
    {
        printf("embargo failed the first test case\n");
    }
    *state = *startingState;
    state->hand[0][4] = embargo;
    updateCoins(0,state,0);
////Embargo Case 2: embargo an invalid kingdom card
    supplyChoice = (rand()%16)+10;
    for(i=0;i<10;i++)
    {
        if(supplyChoice == kingdomCards[i])
        {
            supplyChoice = (rand()%16)+10;
            i = 0;
        }
    }
//    printf("ASDF %d\t%d\n",supplyChoice, kingdomCards[supplyChoice]);
    if(testEmbargo(state,supplyChoice) == -1)
    {
        printf("embargo passed the second test case\n");
    }
    else
    {
        printf("embargo failed the second test case\n");
    }
	
	//test for feast
	*state = *startingState;
	state->hand[0][4] = feast;
	
	//feast Case 1, none of the card choice left
	supplyChoice = -1;
	i =0;
	while(supplyChoice < 0)//make sure kingdom card chosen costs 5 or less
	{
		if(getCost(kingdomCards[i]) > 5)
			i++;
		else
			supplyChoice = kingdomCards[i];
	}
	if(testFeast(state,supplyChoice) == -1)
		printf("Feast Test1 Failed.\n");
	else{
		printf("Feast Test1 Passed.\n");
		}
	/*
	//supplycount 0
	*state = *startingState;
	state->hand[0][4] = feast;
	supplyChoice = -1;
	i=0;
	printf("2\n");
	while(supplyChoice < 0)//make sure kingdom card chosen costs 5 or less
	{
		if(getCost(kingdomCards[i]) > 5){
			i++;
		}
		else
			supplyChoice = kingdomCards[i];
	}
	
	
	state->supplyCount[supplyChoice] = 0; //test when supply count is 0
	if(testFeast(state,supplyChoice) == -1)
		printf("Feast Test2 Passed.\n");
	else
		printf("Feast Test2 Failed.\n");
	
	
	//Feast Case 2: card is too expensive
	*state = *startingState;
	state->hand[0][4] = feast;
	supplyChoice = province;
	if(testFeast(state,supplyChoice) == -1)
		printf("Feast Test3 Passed.\n");
	else
		printf("Feast Test3 Failed.\n");
	*/	
	//remodel test
	*state = *startingState;
	state->hand[0][4] = remodel;
	//test different card values
	//old card value: 0 new card value: 2
	supplyChoice = curse;
	supplyChoice2 = estate;
	if(testRemodel(state,supplyChoice,supplyChoice2) == -1)
		printf("Remodel Test1 Failed.\n");
	else
		printf("Remodel Test1 Passed.\n");
	//old card value: 2 new card value: 4
	*state = *startingState;
	state->hand[0][4] = remodel;
	state->hand[state->whoseTurn][3] = estate;
	supplyChoice = estate;
	supplyChoice2 = feast;
	if(testRemodel(state,3,supplyChoice2) == -1)
		printf("Remodel Test2 Failed.\n");
	else
		printf("Remodel Test2 Passed.\n");
	//old card value: 3 new card value: 5
	*state = *startingState;
	state->hand[0][4] = remodel;
	supplyChoice = silver;
	supplyChoice2 = duchy;
	if(testRemodel(state,supplyChoice,supplyChoice2) == -1)
		printf("Remodel Test3 Failed.\n");
	else
		printf("Remodel Test4 Passed.\n");
	//old card value: 4 new card value: 6
	*state = *startingState;
	state->hand[0][4] = remodel;
	supplyChoice = feast;
	supplyChoice2 = gold;
	if(testRemodel(state,supplyChoice,supplyChoice2) == -1)
		printf("Remodel Test4 Failed.\n");
	else
		printf("Remodel Test4 Passed.\n");
	//old card value: 5 new card value: 6
	*state = *startingState;
	state->hand[0][4] = remodel;
	supplyChoice = duchy;
	supplyChoice2 = gold;
	if(testRemodel(state,supplyChoice,supplyChoice2) == -1)
		printf("Remodel Test5 Failed.\n");
	else
		printf("Remodel Test5 Passed.\n");
	//old card value: 6 new card value: 8
	*state = *startingState;
	state->hand[0][4] = remodel;
	supplyChoice = gold;
	supplyChoice2 = province;
	if(testRemodel(state,supplyChoice,supplyChoice2) == -1)
		printf("Remodel Test6 Failed.\n");
	else
		printf("Remodel Test6 Passed.\n");
	//old card value: 5 new card value: 8
	*state = *startingState;
	state->hand[0][4] = remodel;
	supplyChoice = duchy;
	supplyChoice2 = province;
	if(testRemodel(state,supplyChoice,supplyChoice2) == -1)
		printf("Remodel Test7 Passed.\n");
	else
		printf("Remodel Test7 Failed, player received card that costs more than +2\n");



	//minion test
	*state = *startingState;
	state->hand[0][4] = minion;
	supplyChoice = rand () % 10;
	if(testMinion(state,supplyChoice, supplyChoice2) == -1)
		printf("minion Test1 Failed.\n");
	else
		printf("minion Test1 Passed.\n");
//Smithy Case 1:
    *state = *startingState;
    state->hand[0][4] = smithy;
    if(testSmithy(state) == 0)
        printf("smithy Test1 passed\n");
    else
        printf("smithy Test1 failed\n");
//Steward Case 1:choie 1 +2 cards
    *state = *startingState;
    state->hand[0][4] = steward;
    if(testSteward(state,1,0,0) == 0)
        printf("steward Test1 passed\n");
    else
        printf("steward Test1 failed\n");
//Steward Case 3: choice 2 +2  coins
    *state = *startingState;
    state->hand[0][4] = steward;
    if(testSteward(state,2,0,0) == 0)
        printf("steward Test2 passed\n");
    else
        printf("steward Test2 failed\n");
//Steward Case 4: choice 3, valid
    *state = *startingState;
    state->hand[0][4] = steward;
    if(testSteward(state,2,0,1) == 0)
        printf("steward Test3 passed\n");
    else
        printf("steward Test3 failed\n");
//Steward Case 5: choice 3, invalid same card twice
    *state = *startingState;
    state->hand[0][4] = steward;
    if(testSteward(state,2,0,0) == 0)
        printf("steward Test4 failed\n");
    else
        printf("steward Test4 passed\n");
//Steward Case 5: choice 3, invalid discard steward
    *state = *startingState;
    state->hand[0][4] = steward;
    if(testSteward(state,2,4,0) == 0)
        printf("steward Test5 failed\n");
    else
        printf("steward Test6 passed\n");

	free(startingState);
    free(state);
	return 0;
}

